package com.ymt.reliable.message.service.impl;

import com.ymt.reliable.message.service.TransactionMessageIdService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class UUIDTransactionMessageIdServiceImpl implements TransactionMessageIdService {
    private static final Logger LOGGER = LoggerFactory.getLogger(UUIDTransactionMessageIdServiceImpl.class);
    private static final String REGEX = "-";
    private static final String REPLACEMENT = "";

    @Override
    public String generateId() {
        String id = UUID.randomUUID().toString().replaceAll(REGEX, REPLACEMENT);
        LOGGER.info(">>> 生成消息编号:{}", id);
        return id;
    }
}
